import Vue from 'vue'
import VueRouter from 'vue-router'
import Teacher from '../views/Teacher.vue'
import Student from '../views/Student.vue'
// 导入考试管理 组件
import TeacherExamManage from '../views/TeacherExamManage/TeacherExamManage.vue'
import Find from '../views/TeacherExamManage/Find.vue'
// 导入 成绩管理组件
import XiangQing from '../components/XiangQing.vue'
// import Shijuan from '../components/Shijuan.vue'
import ChengJi from '../components/ChengJi.vue'

// 导入学生模块的两个子组件
import TestList from '../components/student/testlist/TestList.vue'
import MyTest from '../components/student/mytest/MyTest.vue'

import TestDetail from '../components/student/mytest/TestDetail.vue'
// 考试详情的子组件
import RadioAnswer from '../components/student/mytest/detail/RadioAnswer.vue'
import CheckboxAnswer from '../components/student/mytest/detail/CheckboxAnswer.vue'
import Juge from '../components/student/mytest/detail/Juge.vue'
// import ShortAnswer from '../components/student/detail/ShortAnswer.vue'
// import CodeAnswer from '../components/student/detail/CodeAnswer.vue'

// 导入 考试列表 的组件
import Exam from '../components/student/testlist/Exam'
import Radioitem from '../components/student/testlist/item/Radioitem'
import Checkbox from '../components/student/testlist/item/Checkbox'
import TFitem from '../components/student/testlist/item/TFitem'

// 导入问题管理
import Question from '@/components/question/Question.vue'

Vue.use(VueRouter)

const routes = [
  { path: '/', name: 'login', meta: { title: '登录页面', auth: true }, component: () => import('../views/Login.vue') },
  { path: '/register', name: 'register', meta: { title: '注册页面' }, component: () => import('../views/register.vue') },
  {
    path: '/teacher', name: 'teacher', meta: { title: '教师主页面' }, component: Teacher,
    redirect: '/teacher/question',
    // 重定向，默认显示哪个页面
    // redirect: '/teacher/'
    children: [
      // 问题管理模块
      {
        path: 'question',
        name: 'Question',
        meta: { title: '问题管理' },
        component: Question,
      },
      // 考试管理
      {
        path: 'teacherexammanage',
        name: 'teacherexammanage',
        meta: { title: '考试管理' },
        component: TeacherExamManage,
      },
      // 成绩管理
      {
        path: 'chengji',
        name: 'chengji',
        meta: { title: '成绩管理' },
        component: ChengJi,
      },
      // 考试管理模块下查看按钮的跳转
      {
        path: 'find',
        name: 'find',
        component: Find,
        meta: { title: '查看界面' },
        redirect: '/teacher/find/radioitem',
        children: [
          { path: 'radioitem', component: Radioitem },
          { path: 'checkbox', component: Checkbox },
          { path: 'TFitem', component: TFitem }
        ]
      },
      { path: '/xiangqing', name: 'xiangqing', meta: { title: '成绩详情页面' }, component: XiangQing },
      // { path: '/shijuan', name: 'shijuan', component: Shijuan },
    ]
  },
  {
    path: '/student', name: 'student', meta: { title: '学生主页面' }, component: Student,
    redirect: '/student/testlist',
    props: true,
    meta: { istrun: true },
    children: [
      // 考试列表
      {
        path: 'testlist',
        meta: { istrun: true },
        component: TestList,
      },
      // 去考试
      {
        path: 'exam', component: Exam,
        redirect: '/student/exam/radioitem',
        children: [
          { path: 'radioitem', component: Radioitem },
          { path: 'checkbox', component: Checkbox },
          { path: 'TFitem', component: TFitem }
        ]
      },
      // 我的
      {
        path: 'mytest',
        name: 'mytest',
        meta: { title: '我的考试' },
        component: MyTest,
        props: true,
        meta: { istrun: true },
      },
      // 考试详情
      {
        path: 'testdetail',
        name: 'testdetail',
        meta: { title: '考试详情' },
        component: TestDetail,
        redirect: '/student/testdetail/radioanswer',
        children: [
          { path: 'radioanswer', component: RadioAnswer, props: true },
          { path: 'checkboxanswer', component: CheckboxAnswer, },
          { path: 'juge', component: Juge, },
        ]
      }
    ]
  },
  // 成绩管理子模块

  { path: '/chengji', component: ChengJi }

]

const router = new VueRouter({
  routes
})

//路由前置守卫
// router.beforeEach((to,from,next) => {

// })

export default router
